<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$errors = array();

if (isset($_POST['action']) && $_POST['action'] == 'add')
{
	$clas = UV::readMQ($route->POST("clas"));
	$title = UV::readMQ($route->POST("title"));
	$text = UV::readMQ($route->POST("text"));
	
	$query = "insert into `reliability` values(NULL,'$clas','$title','$text')";
	
	$update = $db->sendQuery($query);
	if ($update)
		goToPage("/admin/reliability/edit/".mysql_insert_id());
	else
		$errors[] = "Ошибка добавления записи";
}

loadPage("head.php");
?>
<h1>Добавление класса страхования</h1><br /><?php
	if (count($errors) > 0)
		echo "<p class='fail'>".implode("<br />",$errors)."<br /><br /></p>";
?>
<form method='POST' id='edit'>
	<input type='hidden' name='action' value='add' />
	<table cellpadding='3' cellspacing='5'>
		<tr>
			<td width='170px'><label for='clas'>Класс</label></td>
			<td width='600px'><input type='text' class='short' id='clas' name='clas' value='<?php echo $route->POST('clas'); ?>' /></td>
		</tr>
		<tr>
			<td><label for='title'>Заголовок</label></td>
			<td><input type='text' id='title' name='title' value='<?php echo $route->POST('title'); ?>' /></td>
		</tr>
		<tr>
			<td><label for='text'>Текст</label></td>
			<td><textarea id='text' name='text'><?php echo $route->POST('text'); ?></textarea></td>
		</tr>
		<tr>
			<td colspan='2' align='right'><input type='submit' value='Добавить' /></td>
		</tr>
	</table>
</form>

<?php loadPage("footer.php"); ?>